package main.java.tmi.authority.service.impl;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import main.java.tmi.common.service.impl.AbstractDao;
import main.java.tmi.authority.service.AuthorityVO;
import main.java.tmi.authority.service.RoleVO;

import org.springframework.stereotype.Repository;

/**
 * Authority Data Access Object (cust Table)
 *
 * @author min™
 * @since 2012. 04. 24
 */
@Repository
public class AuthorityDAO extends AbstractDao {
	
	/**
	 * Authority search
	 * @return List<AuthorityVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public List<AuthorityVO> getAuthorityView(Map<String,String> param) throws SQLException {
				
		return (List<AuthorityVO>) list("AuthorityDAO.getAuthorityView", param);
	}
	
	/**
	 * Authority search
	 * @return List<AuthorityVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public int getAuthorityViewCount(Map<String,String> param) throws SQLException {
		return Integer.parseInt((String) getSqlMapClientTemplate().queryForObject("AuthorityDAO.getAuthorityViewCount", param));
	}
	
	/**
	 * Authority search
	 * @return List<AuthorityVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public Map<String,String>  getAuthorityDetailView(Map<String,String> param) throws SQLException {
		Map<String,String> returnMap ;
        returnMap = (Map<String,String>) selectByPk("AuthorityDAO.getAuthorityDetailView", param);
        
        return returnMap;
	}
	
	/**
	 * Authority save
	 * @return void
	 * @throws SQLException 
	 */
	public void addAuthority(Map<String,String> param) throws SQLException {
		insert("AuthorityDAO.addAuthority", param);
	}
	
	/**
	 * Authority modify
	 * @return void
	 * @throws SQLException 
	 */
	public void modifyAuthority(Map<String,String> param) throws SQLException {
		insert("AuthorityDAO.modifyAuthority", param);
	}
	
	/**
	 * Authority del
	 * @return void
	 * @throws SQLException 
	 */
	public void delAuthority(Map<String,String> param) throws SQLException {
		insert("AuthorityDAO.delAuthority", param);
	}	
	
	/**
	 * Rolelist select
	 * @return List<AuthorityVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public List<RoleVO> getRolelist(Map<String,String> param) throws SQLException {
				
		return (List<RoleVO>) list("AuthorityDAO.getRoleList", param);
	}
}
